// 标签模块接口集合
import request from './request.js'

/**
 * 创建新标签
 */
export const createTag = (tag) => {
	return request.post('/tags', tag)
}

/**
 * 更新标签信息
 */
export const updateTag = (tag) => {
	return request.put('/tags', tag)
}

/**
 * 删除标签
 * @param {number} id 标签ID
 */
export const deleteTag = (id) => {
	return request.delete(`/tags/${id}`)
}

/**
 * 获取标签详情
 * @param {number} id 标签ID
 */
export const getTagById = (id) => {
	return request.get(`/tags/${id}`)
}

/**
 * 获取所有标签
 */
export const getAllTags = () => {
	return request.get('/tags')
}

/**
 * 根据名称获取标签
 * @param {string} name 标签名称
 */
export const getTagByName = (name) => {
	return request.get('/tags/by-name', {
		params: {
			name
		}
	})
}